package cn.ren.cloud.feign;

import cn.ren.cloud.domain.Login;
import cn.ren.cloud.enums.GlobelExceptionEnum;
import cn.ren.cloud.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author 23508
 */
@Component
public class LoginFeinClientFallbackFactory implements FallbackFactory<LoginFeinClient> {

    @Override
    public LoginFeinClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new LoginFeinClient() {
            @Override
            public JsonResult saveOrUpdate(Login login) {
                return JsonResult.error(GlobelExceptionEnum.COMMON_REPEAT_OPERATION_ERROR.getMessage(), GlobelExceptionEnum.COMMON_REPEAT_OPERATION_ERROR.getCode());
            }
        };
    }
}
